package com.block.test.reqbean.convert;

import cn.hutool.core.lang.UUID;
import com.block.test.reqbean.source.CheckUserInfo;
import com.block.test.reqbean.source.JiXiangYouQianUserInfo;

/**
 * @Author: ld
 * @Date: 2024-08-26 13:49
 * @Description:
 * @Version: 1.0
 **/
public class CheckUserConvert {


    public static CheckUserInfo jiXiangUserInfo2CheckUser(JiXiangYouQianUserInfo arg) {
        CheckUserInfo source = new CheckUserInfo();
        if ("2年以上".equals(arg.getInsurance())) {
            source.setBaodan("bd004");
        } else if ("2年以下".equals(arg.getInsurance())) {
            source.setBaodan("bd003");
        } else {
            source.setBaodan("bd001");
        }
        source.setCity(arg.getCityName());
        source.setPurpose("pu003");
        source.setEnterpriseOwner("eo001");
        if ("私营企业主".equals(arg.getOccupation())) {
            source.setEnterpriseOwner("eo002");
            source.setJob("job002");
        } else if ("上班族".equals(arg.getOccupation())) {
            source.setJob("job002");
        } else if ("自由职业".equals(arg.getOccupation())) {
            source.setJob("job003");
        } else {
            source.setJob("job004");
        }
        source.setProvince(convertProvince(arg.getProvinceName()));
        if ("6个月以下".equals(arg.getAccumulation())) {
            source.setGjj("gjj002");
        } else if ("6个月以上".equals(arg.getAccumulation())) {
            source.setGjj("gjj003");
        } else {
            source.setGjj("gjj001");
        }
        source.setSex(arg.getSex());
        if ("6个月以下".equals(arg.getSocialSecurity())) {
            source.setShebao("sb002");
        } else if ("6个月以上".equals(arg.getSocialSecurity())) {
            source.setShebao("sb003");
        } else {
            source.setShebao("sb001");
        }
        source.setOutOrderNo(UUID.randomUUID().toString().replaceAll("-", ""));
        source.setMobileMd5(arg.getUserPhone().toLowerCase());
        source.setSalary("sa002");
        source.setYuqi("yq001");
        if ("当前有逾期".equals(arg.getOverdueSituation())) {
            source.setYuqi("yq002");
        }
        source.setHouse("hu001");
        if ("有".equals(arg.getHouse())) {
            source.setHouse("hu002");
        }
        source.setLoanAmount("la001");
        if ("10万".equals(arg.getLoanAmount())) {
            source.setLoanAmount("la002");
        } else {
            source.setLoanAmount("la003");
        }
        source.setRealName(arg.getUserName());
        source.setLoanTime("lt002");
        source.setXueli("xl003");
        if ("700分以上".equals(arg.getNewSesameSeed())) {
            source.setZhimaScore("zm005");
        } else if ("650-699分".equals(arg.getNewSesameSeed())) {
            source.setZhimaScore("zm004");
        } else if ("600-649分".equals(arg.getNewSesameSeed())) {
            source.setZhimaScore("zm003");
        } else {
            source.setZhimaScore("zm002");
        }
        source.setCar("car001");
        if ("有".equals(arg.getCar())) {
            source.setCar("car003");
        }
        source.setUserIp(arg.getUserIp());
        source.setAge(arg.getAge());
        return source;
    }


    private static String convertProvince(String province) {
        if ("北京".equals(province) || "天津".equals(province) || "上海".equals(province) || "重庆".equals(province)) {
            return province + "市";
        } else if ("内蒙古自治区".equals(province) || "广西壮族自治区".equals(province) || "宁夏回族自治区".equals(province)
                || "新疆维吾尔自治区".equals(province) || "西藏自治区".equals(province) || "香港特别行政区".equals(province)
                || "澳门特别行政区".equals(province)) {
            return province;
        } else {
            return province + "省";
        }
    }
}
